<script type="text/javascript">
        function onChekAll(){
			var f=document.frmAdmin;
			var items=document.getElementsByName('cbOne');
			if(f.cbAll.checked){
				for(i=0; i<items.length; i++){
					items[i].checked=true;
				}
			}else{
				for(i=0; i<items.length; i++){
					items[i].checked=false;
				}
			}
		}
        function isCheck(){
			var c=0;
			var items=document.getElementsByName('cbOne');
			var listId="";
			for(i=0; i<items.length; i++){
					if(items[i].checked==true){
						c=1;
						listId+=items[i].value+',';
					}
			}
			if(c==1){
				c=listId;
			}
			return c;
		}
        function onDel(){
			var f=document.frmAdmin;
			var listId=isCheck();
			listId=listId+'0';
			if(isCheck()==0){
				alert("Bạn chưa chọn người dùng để xoá");
				return false;
			}else{
				if(confirm("Bạn muốn xoá người dùng đã chọn?")){
					//f.actDel.value="1";
					//f.submit();
					window.location.href="<?php echo $this->baseUrl()?>/admin/user/delete/listId/"+listId;
				}
			}
		}
</script>
<div class="heading">
    <div class="left_heading"></div>
                                
    <div class="content_heading">
        <h3>Quản lý thành viên</h3>
    </div>
                                
    <div class="right_heading"></div>
</div><!-- End .heading -->

<div class="main_content">
    <div class="table_form">
        <form class="search_form" name="search_form" action="" method="get">
       Tìm kiếm: 
        <input class="input" type="text" name="keyword" value="<?php echo $this->searchValue; ?>" />
        <input class="button" type="submit" name="search" value="Tìm kiếm" />
        <span class="msg"><?php echo $this->errorSearch; ?></span>
        </form>
        
        <form class="list_cat_form" action="" method="post" name="frmAdmin">
        <div style="float: right;">
        	<p id="add_form">Số lượng: <span class="msg"><?php echo $this->total; ?> </span> thành viên</p>
	        <?php echo $this->formSubmit('add', 'Thêm mới', array('class' => 'button', 'id' => 'add_form')); ?>
            <input type="button" value="Xoá" class="button" onclick="onDel()" id="del_form"  />
	        
        </div>                   
        <table class="table_style">
            <tr class="head_table">
                <td width="100px">Họ tên</td>
                <td width="70px">Ngày sinh</td>
                <td width="70px">Ảnh đại diện</td>
                <td width="80px">Địa chỉ mail</td>
                <td width="70px">số điện thoại</td>
                <td class="tools">&nbsp;</td>
                <td class="tools">&nbsp;</td>
                <td class="tools"><input type="checkbox" name="cbAll" onclick="onChekAll()" id="check_all"/> </td>
            </tr>
           <?php
                if(count($this->data) > 0) :
                foreach($this->data as $row) :
                $sql_date = strtotime($row->birthday);
                $birthday = date('d/m/Y', $sql_date);
            ?>
            <tr class="records">
                
                <td><?php echo $row->fullname; ?></td>
                <td><?php echo $birthday; ?></td>
                <td>
                    <?php if($row->avatar!=''): ?>
                        <img class="img_avatar" width="60px" height="50px" src="<?php echo $this->baseUrl('/public/img/user/'.$row->avatar) ?>"/>
                    <?php else:?>                       
                        <img class="img_avatar" width="60px" height="50px" src="<?php echo $this->baseUrl('/public/img/user/default.jpg') ?>"/>
                    <?php endif;  ?>
                </td>
                <td><?php echo $row->email; ?></td>
            	<td><?php echo $row->phone; ?></td>
                <td><a class="edit" title="Sửa" href="<?php echo $this->baseUrl('/admin/user/edit/id/'.$row->user_id) ?>"></a></td>
                <td><a class="remove" title="Xóa" onclick="return remove_alert()" href="<?php echo $this->baseUrl('/admin/user/delete/id/'.$row->user_id) ?>"></a></td>
                <td><input type="checkbox" name="cbOne" value="<?php echo $row->user_id; ?>" /></td>
            </tr>
            <?php 
                endforeach;
                else :
            ?>
            <tr class="records">
            	<td colspan="8">Không tìm thấy thành viên nào!</td>
            </tr>
            <?php endif; ?>
        </table>
        </form>
    </div>
    
    <div class="pagination">
        <?php echo $this->paginationControl($this->data, 'Sliding', 'user/pagination.phtml'); ?>
    </div>
</div><!-- End .main_content -->  